#define _CRT_SECURE_NO_WARNINGS  1

#include <iostream>
using namespace std;

int Getday(int year, int month, int day)
{
    int Day = day;
    int Month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
    {
        Month[1]++;
    }
    for (int i = 0; i < month - 1; i++)
    {
        Day += Month[i];
    }
    return Day;
}

int main()
{
    int year, month, day;
    while (cin >> year >> month >> day)
    {
        cout << Getday(year, month, day) << endl;
    }
}
